package dormouse.vfs.ui.renderers;

import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.Map.Entry;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

import org.apache.commons.vfs2.*;

public class FileRendererPanel extends JPanel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4076092663764600402L;
	CardLayout cd = new CardLayout();
	
	/**
	 * Constructor
	 */
	public FileRendererPanel(){
		
		initialize();
	}
		
	
	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {
		this.setPreferredSize(new Dimension(200, 200));	
		this.setBorder(BorderFactory.createTitledBorder("Preview"));
		this.setSize(new Dimension(191, 122));
		this.setLayout(cd);
		
		IFileRenderer currRenderer = null;
		String rendererName = null;
		for(Entry<String, IFileRenderer> entry : FileRendererFactory.rendererMap.entrySet()){
			rendererName = entry.getKey();
			currRenderer = entry.getValue();
			cd.addLayoutComponent((Component)currRenderer, rendererName);
		}
	}

	public void render(FileObject fo){
		IFileRenderer renderer = FileRendererFactory.getInstance(fo);
                renderer.render(fo);
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
